<?php 
/**
 * eBay Label Printing Program Article Category Database Table Class 
 * this is a Db Table Class , It stores Article Category structure, category is the sub structure of section
 * @package  eBayLabelPrinter
 * @category Models/DbTable
 * @author   Norman Dong <norman.dong@hotmail.com>
 * @version  Initial
 * @copyright LeadCasket.com
 * @link     www.leadcasket.com
 * @license  Commercial
 */
 class Model_DbTable_Cms_Articlecategory extends Zend_Db_Table_Abstract 
{
	/**
	 * @var string Class Table Name
	 */
	protected $_name = 'article_category'; 
	/**
	 * Get Seller Group By ID 
	 * Not decide what to do Yet
	 * @param int $idSeller  The Seller ID
	 * @return array  Not decide what to return 
	 */	
	public function getArticleCategory($articleCategoryID){
		
		$row = $this->fetchRow('`id_category_article`='.(int)$articleCategoryID);
		if(!$row){
			return false;
		}
		return $row->toArray();		
	}	
	public function addArticleCategory($articleCategoryTitle,$articleCategoryPosition,$sectionID,$available){
		
		$data = array(
				'title_category_article' => $articleCategoryTitle,
				'position_category_article'=>$articleCategoryPosition,
				'id_section_category_article'=>$sectionID,
				'available_category_article'=>$available
				);
		$this->insert($data);
	}
	public function updateArticleCategory($articleCategoryID,$articleCategoryTitle,$articleCategoryPosition,$sectionID,$available){
		
		$data = array(
				'title_category_article' => $articleCategoryTitle,
				'position_category_article'=>$articleCategoryPosition,
				'id_section_category_article'=>$sectionID,
				'available_category_article'=>$available
		);		
		
		$this->update($data,'id_category_article ='.$articleCategoryID);
	}
	public function deleteArticleCategory($articleCategoryID){
		$this->delete('id_category_article =' . $articleCategoryID);
	}
	public function listCategoryBySection($sectionID){
		$order = new Zend_Db_Expr('`position_category_article`');
		$rows = $this->fetchAll('`id_section_category_article` ='.(int)$sectionID,$order);
		if(empty($rows)){
			return false;
		}
		return $rows->toArray();
	}
	public function listCategory(){
		$order = new Zend_Db_Expr('`position_category_article`');
		$rows = $this->fetchAll('1',$order);
		if(empty($rows)){
			return false;
		}
		return $rows->toArray();
		
	}
}
?>